package com.polytech.dao.hibernate;

import java.util.Collection;
import java.util.List;

import org.hibernate.Query;

import com.polytech.beans.Category;
import com.polytech.beans.Color;
import com.polytech.dao.ColorDao;

public class ColorDaoHibernate extends AbstractHibernateDao implements ColorDao {
	@Override
	public void insert(Color color) {
		beginTransaction();
			session.save(color);
		commit();
	}

	@Override
	public Color select(String key) {
		beginTransaction();
			Color color=(Color) session.get(Color.class,key);
		commit();
		return color;
	}

	@Override
	public void remove(Color color) {
		beginTransaction();
			session.delete(color);
		commit();
	}

	@Override
	public Collection<Color> selectAll() {
		List<Color> res=null;
		beginTransaction();
			res= (List<Color>) session.createQuery("from Color").list();
		commit();
		return res;
	}


}
